package com.neu.chenzhiping.Servlet;

import com.neu.chenzhiping.Service.MgrService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

@WebServlet(name = "MgrLoginServlet", urlPatterns = {"/MgrLoginServlet.do"})
public class MgrLoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            request.setCharacterEncoding("utf-8");

            String no=request.getParameter("no");
            String pwd=request.getParameter("pwd");

         Map<String,Object>item=null;
         MgrService s=new MgrService();
         item= s.Login(no,pwd);
         boolean flag=false;
        if (item.size()>0){
            HttpSession session=request.getSession();
            session.setAttribute("items",item);
            flag=true;

        }

        PrintWriter out=response.getWriter();
        out.print(flag);
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);

    }
}
